<!DOCTYPE html>





<html class="theme-next muse use-motion" lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="generator" content="Hexo 3.9.0">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=7.3.0">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=7.3.0">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=7.3.0">
  <link rel="mask-icon" href="/images/logo.svg?v=7.3.0" color="#222">

<link rel="stylesheet" href="/css/main.css?v=7.3.0">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css?v=4.7.0">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    version: '7.3.0',
    exturl: false,
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":false},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
    save_scroll: false,
    copycode: {"enable":false,"show_result":false,"style":null},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: '',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    translation: {
      copy_button: '复制',
      copy_success: '复制成功',
      copy_failure: '复制失败'
    }
  };
</script>

  <meta name="description" content="下载安装 NOODS下载NOODS的镜像文件，解压。下载地址：https://www.raspberrypi.org/downloads/noobs/ 格式化SD卡访问网站，下载Format4.0 https://www.sdcard.org 复制解压后文件夹内的文件到SD卡中，然后重启默认用户名：pi密码：raspberry">
<meta name="keywords" content="树莓派">
<meta property="og:type" content="article">
<meta property="og:title" content="树莓派上的Web Cam">
<meta property="og:url" content="http://yoursite.com/2018/05/17/树莓派上的Web Cam/index.html">
<meta property="og:site_name" content="XuQi&#39;s Blog">
<meta property="og:description" content="下载安装 NOODS下载NOODS的镜像文件，解压。下载地址：https://www.raspberrypi.org/downloads/noobs/ 格式化SD卡访问网站，下载Format4.0 https://www.sdcard.org 复制解压后文件夹内的文件到SD卡中，然后重启默认用户名：pi密码：raspberry">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://cl.ly/2m0V1x2h2r25/Image%202016-02-23%20at%201.16.04%20%E4%B8%8B%E5%8D%88.png">
<meta property="og:image" content="http://cl.ly/0N173H3i2p0M/Image%202016-02-23%20at%201.31.58%20%E4%B8%8B%E5%8D%88.png">
<meta property="og:image" content="http://cl.ly/0p2I1e2p382L/Image%202016-02-23%20at%201.32.40%20%E4%B8%8B%E5%8D%88.png">
<meta property="og:image" content="http://cl.ly/2b2h2100051c/Image%202016-02-23%20at%208.31.30%20%E4%B8%8B%E5%8D%88.png">
<meta property="og:updated_time" content="2019-10-20T13:23:23.049Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="树莓派上的Web Cam">
<meta name="twitter:description" content="下载安装 NOODS下载NOODS的镜像文件，解压。下载地址：https://www.raspberrypi.org/downloads/noobs/ 格式化SD卡访问网站，下载Format4.0 https://www.sdcard.org 复制解压后文件夹内的文件到SD卡中，然后重启默认用户名：pi密码：raspberry">
<meta name="twitter:image" content="http://cl.ly/2m0V1x2h2r25/Image%202016-02-23%20at%201.16.04%20%E4%B8%8B%E5%8D%88.png">
  <link rel="canonical" href="http://yoursite.com/2018/05/17/树莓派上的Web Cam/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true,
    isPage: false,
    isArchive: false
  };
</script>

  <title>树莓派上的Web Cam | XuQi's Blog</title>
  








  <noscript>
  <style>
  .use-motion .motion-element,
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-title { opacity: initial; }

  .use-motion .logo,
  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  <div class="container sidebar-position-left">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta">

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">XuQi's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
      
      
      
        
        <li class="menu-item menu-item-home">
      
    

    <a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-archives">
      
    

    <a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i> <br>归档</a>

  </li>
  </ul>

    

</nav>
</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content page-post-detail">
            

  <div id="posts" class="posts-expand">
    

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/05/17/树莓派上的Web Cam/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="XuQi">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="XuQi's Blog">
    </span>
      <header class="post-header">

        
          <h1 class="post-title" itemprop="name headline">树莓派上的Web Cam

            
          </h1>
        

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              
                
              

              <time title="创建时间：2018-05-17 19:52:00" itemprop="dateCreated datePublished" datetime="2018-05-17T19:52:00+00:00">2018-05-17</time>
            </span>
          
            

            
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2019-10-20 13:23:23" itemprop="dateModified" datetime="2019-10-20T13:23:23+00:00">2019-10-20</time>
              </span>
            
          

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h3 id="下载安装-NOODS"><a href="#下载安装-NOODS" class="headerlink" title="下载安装 NOODS"></a>下载安装 NOODS</h3><h4 id="下载NOODS的镜像文件，解压。"><a href="#下载NOODS的镜像文件，解压。" class="headerlink" title="下载NOODS的镜像文件，解压。"></a>下载NOODS的镜像文件，解压。</h4><p>下载地址：<a href>https://www.raspberrypi.org/downloads/noobs/</a></p>
<h4 id="格式化SD卡"><a href="#格式化SD卡" class="headerlink" title="格式化SD卡"></a>格式化SD卡</h4><p>访问网站，下载Format4.0 <a href>https://www.sdcard.org</a></p>
<h4 id="复制解压后文件夹内的文件到SD卡中，然后重启"><a href="#复制解压后文件夹内的文件到SD卡中，然后重启" class="headerlink" title="复制解压后文件夹内的文件到SD卡中，然后重启"></a>复制解压后文件夹内的文件到SD卡中，然后重启</h4><p>默认用户名：pi<br>密码：raspberry</p>
<a id="more"></a>

<h3 id="开机基本设置"><a href="#开机基本设置" class="headerlink" title="开机基本设置"></a>开机基本设置</h3><h4 id="开机自动连接"><a href="#开机自动连接" class="headerlink" title="开机自动连接"></a>开机自动连接</h4><p>详细说明：<br><a href>http://www.educity.cn/wenda/565819.html</a></p>
<h4 id="安装虚拟的环境"><a href="#安装虚拟的环境" class="headerlink" title="安装虚拟的环境"></a>安装虚拟的环境</h4><p><a href>http://blog.csdn.net/xshalk/article/details/47301339</a></p>
<h4 id="安装OpenCV"><a href="#安装OpenCV" class="headerlink" title="安装OpenCV"></a>安装OpenCV</h4><p><a href>http://python.jobbole.com/81106/</a></p>
<h4 id="使用ssh-X连接raspberry"><a href="#使用ssh-X连接raspberry" class="headerlink" title="使用ssh -X连接raspberry"></a>使用ssh -X连接raspberry</h4><p><a href>http://unix.stackexchange.com/questions/12755/how-to-forward-x-over-ssh-from-ubuntu-machine</a></p>
<h4 id="on-the-client-side"><a href="#on-the-client-side" class="headerlink" title="on the client side:"></a>on the client side:</h4><ul>
<li><p>如果使用的是ssh -X pi@ServerNamel连接的，请确保<a href>~/.ssh/config</a>中有<code>ForwardX11 yes</code>。如果没有<a href>~/.ssh/config</a>也可以通过<code>ssh -o ForwardX11=yes blyman@the-server</code><br>这种方式启动</p>
</li>
<li><p>Mac电脑的X11更新到最新版本<br><img src="http://cl.ly/2m0V1x2h2r25/Image%202016-02-23%20at%201.16.04%20%E4%B8%8B%E5%8D%88.png" alt></p>
</li>
</ul>
<h4 id="on-the-raspberry-side-Server"><a href="#on-the-raspberry-side-Server" class="headerlink" title="on the raspberry side(Server):"></a>on the raspberry side(Server):</h4><ul>
<li>检查<code>/etc/ssh/sshd_config</code>是否包含<code>X11Forwarding yes</code></li>
<li>检查xauth，运行<code>which xauth</code>,如果显示路径了，表示正确。</li>
</ul>
<p><strong>Tip</strong>：DISPLAY这个环境变量是自动设置的，可以通过检查连接的log信息来判断，<br>打开log的方法：<br><code>ssh -X -v pi@ServerName</code></p>
<p>如果log信息中有：<br><code>debug1: X11 forwarding requested but DISPLAY not set</code></p>
<p>可以在服务端输入：<br><code>export DISPLAY=:0.0</code></p>
<h4 id="测试："><a href="#测试：" class="headerlink" title="测试："></a>测试：</h4><p>连接：<br><img src="http://cl.ly/0N173H3i2p0M/Image%202016-02-23%20at%201.31.58%20%E4%B8%8B%E5%8D%88.png" alt></p>
<p>打开了leafpad<br><img src="http://cl.ly/0p2I1e2p382L/Image%202016-02-23%20at%201.32.40%20%E4%B8%8B%E5%8D%88.png" alt></p>
<h3 id="第一个Web-Cam"><a href="#第一个Web-Cam" class="headerlink" title="第一个Web Cam"></a>第一个Web Cam</h3><ul>
<li><p>clone 以下工程：<br><code>git clone git@github.com:xuqi1987/pystream.git</code></p>
</li>
<li><p>安装Flask<br><code>pip install Flask</code></p>
</li>
<li><p>运行服务器<br><code>python stream.py</code>,输入ip:0.0.0.0.在浏览器中打开192.168.1.113:5000</p>
</li>
</ul>
<p>运行效果图：<br><img src="http://cl.ly/2b2h2100051c/Image%202016-02-23%20at%208.31.30%20%E4%B8%8B%E5%8D%88.png" alt></p>
<h3 id="mac-安装open-cv"><a href="#mac-安装open-cv" class="headerlink" title="mac 安装open cv"></a>mac 安装open cv</h3><ol>
<li>安装braw</li>
</ol>
<p><a href>http://brew.sh/index_zh-cn.html</a></p>
<p>2.通过braw安装cmake<br><code>braw install cmake</code></p>
<ol start="2">
<li><p>取的open cv的代码，两种方法：(因为raspberry上装的版本是2.4.10，所以mac上也下这个版本)</p>
<ul>
<li>方法1 下载<a href>https://sourceforge.net/projects/opencvlibrary/files/opencv-unix/
  </a>    </li>
<li>方法2 取git hub 上clone <a href>https://github.com/Itseez/opencv</a>，clone成功后，创建分支<code>git checkout -b 2.4.10.4 2.4.10.4</code></li>
</ul>
</li>
<li><p>因为2.4.10.4有个bug，会导致变异失败，可以先解决这个bug。<br> <strong>bug</strong>：<a href>https://github.com/Itseez/opencv/pull/3488/files
</a></p>
</li>
</ol>
<p>解决方法：<code>git checkout 35f96d6da76099d80180439c857a4abe5cb17966 ./modules/legacy/src/calibfilter.cpp</code></p>
<p>4.编译和安装</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">sudo cmake -G &quot;Unix Makefiles&quot;</span><br><span class="line">sudo make -j8</span><br><span class="line">sudo make install</span><br></pre></td></tr></table></figure>

<h3 id="open-cv-教程"><a href="#open-cv-教程" class="headerlink" title="open cv 教程"></a>open cv 教程</h3><p>相关教程<br><a href>http://blog.csdn.net/sunny2038/article/details/9057415
</a></p>
<h3 id="安装-markdown2"><a href="#安装-markdown2" class="headerlink" title="安装 markdown2"></a>安装 markdown2</h3><p><a href>http://hao.jobbole.com/python-markdown2/
</a></p>
<h3 id="安装-PIL"><a href="#安装-PIL" class="headerlink" title="安装 PIL"></a>安装 PIL</h3><p>无法通过 <code>pip install pil</code> 安装。</p>
<p>解决办法：<br><code>pip install pillow</code></p>
<p><a href>http://stackoverflow.com/questions/20060096/installing-pil-with-pip</a></p>

    </div>

    
    
    
        
      

      <footer class="post-footer">
          
            
          
          <div class="post-tags">
            
              <a href="/tags/树莓派/" rel="tag"># 树莓派</a>
            
          </div>
        

        

          <div class="post-nav">
            <div class="post-nav-next post-nav-item">
              
                <a href="/2018/04/25/Linux进程介绍/" rel="next" title="Linux进程">
                  <i class="fa fa-chevron-left"></i> Linux进程
                </a>
              
            </div>

            <span class="post-nav-divider"></span>

            <div class="post-nav-prev post-nav-item">
              
                <a href="/2018/05/17/Iptables基本知识/" rel="prev" title="Iptables基础知识">
                  Iptables基础知识 <i class="fa fa-chevron-right"></i>
                </a>
              
            </div>
          </div>
        
      </footer>
    
  </div>
  
  
  
  </article>

  </div>


          </div>
          

        </div>
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-overview">

          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">XuQi</p>
  <div class="site-description motion-element" itemprop="description"></div>
</div>
  <nav class="site-state motion-element">
      <div class="site-state-item site-state-posts">
        
          <a href="/archives/">
        
          <span class="site-state-item-count">44</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-tags">
        
        
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
        <span class="site-state-item-count">30</span>
        <span class="site-state-item-name">标签</span>
        
      </div>
    
  </nav>



        </div>
      </div>
      <!--noindex-->
        <div class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
            
            
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#下载安装-NOODS"><span class="nav-number">1.</span> <span class="nav-text">下载安装 NOODS</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#下载NOODS的镜像文件，解压。"><span class="nav-number">1.1.</span> <span class="nav-text">下载NOODS的镜像文件，解压。</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#格式化SD卡"><span class="nav-number">1.2.</span> <span class="nav-text">格式化SD卡</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#复制解压后文件夹内的文件到SD卡中，然后重启"><span class="nav-number">1.3.</span> <span class="nav-text">复制解压后文件夹内的文件到SD卡中，然后重启</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#开机基本设置"><span class="nav-number">2.</span> <span class="nav-text">开机基本设置</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#开机自动连接"><span class="nav-number">2.1.</span> <span class="nav-text">开机自动连接</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#安装虚拟的环境"><span class="nav-number">2.2.</span> <span class="nav-text">安装虚拟的环境</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#安装OpenCV"><span class="nav-number">2.3.</span> <span class="nav-text">安装OpenCV</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#使用ssh-X连接raspberry"><span class="nav-number">2.4.</span> <span class="nav-text">使用ssh -X连接raspberry</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#on-the-client-side"><span class="nav-number">2.5.</span> <span class="nav-text">on the client side:</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#on-the-raspberry-side-Server"><span class="nav-number">2.6.</span> <span class="nav-text">on the raspberry side(Server):</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#测试："><span class="nav-number">2.7.</span> <span class="nav-text">测试：</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#第一个Web-Cam"><span class="nav-number">3.</span> <span class="nav-text">第一个Web Cam</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#mac-安装open-cv"><span class="nav-number">4.</span> <span class="nav-text">mac 安装open cv</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#open-cv-教程"><span class="nav-number">5.</span> <span class="nav-text">open cv 教程</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#安装-markdown2"><span class="nav-number">6.</span> <span class="nav-text">安装 markdown2</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#安装-PIL"><span class="nav-number">7.</span> <span class="nav-text">安装 PIL</span></a></li></ol></div>
            

          </div>
        </div>
      <!--/noindex-->
      

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">XuQi</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v3.9.0</div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">主题 – <a href="https://theme-next.org" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> v7.3.0</div>

        








        
      </div>
    </footer>
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
      </div>

    

  </div>

  
  <script src="/lib/jquery/index.js?v=3.4.1"></script>
  <script src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  <script src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

<script src="/js/utils.js?v=7.3.0"></script>
  <script src="/js/motion.js?v=7.3.0"></script>


  <script src="/js/schemes/muse.js?v=7.3.0"></script>


<script src="/js/next-boot.js?v=7.3.0"></script>




  




























  

  

  


  
  <script src="/js/scrollspy.js?v=7.3.0"></script>
<script src="/js/post-details.js?v=7.3.0"></script>


</body>
</html>
